/*
 *  Copyright (C) 2011 Jaytter Team
 * 
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 * 
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 * 
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/*
 * InitWindow.java
 *
 * Created on 13/06/2011, 10:48:24
 */
package org.jaytter.ui.main;

import org.jaytter.ui.panels.login.AccountsList;
import org.jaytter.ui.panels.login.NewAccountDialog;

/**
 *
 * @author Jaytter Team
 */
public class InitWindow extends javax.swing.JFrame {

    /** Creates new form InitWindow */
    public InitWindow() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        painelContainerLogin = new javax.swing.JPanel();
        painelAdicionarConta = new javax.swing.JPanel();
        botaoAdicionarConta = new javax.swing.JButton();
        painelContas = new javax.swing.JPanel();
        painelBaixo = new javax.swing.JPanel();
        barraMenu = new javax.swing.JMenuBar();
        menuTwitter = new javax.swing.JMenu();
        menuTwitterExit = new javax.swing.JMenuItem();
        menuEdit = new javax.swing.JMenu();
        menuHelp = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("JayTTer");
        setLocationByPlatform(true);
        setMinimumSize(new java.awt.Dimension(320, 660));
        getContentPane().setLayout(new javax.swing.BoxLayout(getContentPane(), javax.swing.BoxLayout.LINE_AXIS));

        painelContainerLogin.setBackground(new java.awt.Color(51, 51, 0));
        painelContainerLogin.setLayout(new java.awt.BorderLayout());

        painelAdicionarConta.setBackground(new java.awt.Color(204, 255, 51));

        botaoAdicionarConta.setText("Adicionar Conta");
        botaoAdicionarConta.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botaoAdicionarContaActionPerformed(evt);
            }
        });
        painelAdicionarConta.add(botaoAdicionarConta);

        painelContainerLogin.add(painelAdicionarConta, java.awt.BorderLayout.NORTH);

        painelContas.setBackground(new java.awt.Color(0, 255, 102));
        painelContainerLogin.add(painelContas, java.awt.BorderLayout.CENTER);

        painelBaixo.setPreferredSize(new java.awt.Dimension(306, 250));

        javax.swing.GroupLayout painelBaixoLayout = new javax.swing.GroupLayout(painelBaixo);
        painelBaixo.setLayout(painelBaixoLayout);
        painelBaixoLayout.setHorizontalGroup(
            painelBaixoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        painelBaixoLayout.setVerticalGroup(
            painelBaixoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 250, Short.MAX_VALUE)
        );

        painelContainerLogin.add(painelBaixo, java.awt.BorderLayout.SOUTH);

        getContentPane().add(painelContainerLogin);

        menuTwitter.setText("Twitter");

        menuTwitterExit.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Q, java.awt.event.InputEvent.CTRL_MASK));
        menuTwitterExit.setText("Sair");
        menuTwitterExit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuTwitterExitActionPerformed(evt);
            }
        });
        menuTwitter.add(menuTwitterExit);

        barraMenu.add(menuTwitter);

        menuEdit.setText("Editar");
        barraMenu.add(menuEdit);

        menuHelp.setText("Ajuda");
        barraMenu.add(menuHelp);

        setJMenuBar(barraMenu);

        getAccessibleContext().setAccessibleDescription("JayTter, O Cliente Twitter multiplataforma");

        pack();
        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        java.awt.Dimension dialogSize = getSize();
        setLocation((screenSize.width-dialogSize.width)/2,(screenSize.height-dialogSize.height)/2);
    }// </editor-fold>//GEN-END:initComponents

    private void menuTwitterExitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuTwitterExitActionPerformed
        System.exit(0);
    }//GEN-LAST:event_menuTwitterExitActionPerformed

    private void botaoAdicionarContaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botaoAdicionarContaActionPerformed
        NewAccountDialog d = new NewAccountDialog(this, true);
        d.setVisible(true);
    }//GEN-LAST:event_botaoAdicionarContaActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuBar barraMenu;
    private javax.swing.JButton botaoAdicionarConta;
    private javax.swing.JMenu menuEdit;
    private javax.swing.JMenu menuHelp;
    private javax.swing.JMenu menuTwitter;
    private javax.swing.JMenuItem menuTwitterExit;
    private javax.swing.JPanel painelAdicionarConta;
    private javax.swing.JPanel painelBaixo;
    private javax.swing.JPanel painelContainerLogin;
    private javax.swing.JPanel painelContas;
    // End of variables declaration//GEN-END:variables

    public void updateAccountsList() {
        AccountsList listaDeContas = new AccountsList(this);
        painelContas.add(listaDeContas);

        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                painelContas.repaint();
            }
        });
    }
}
